#include <iostream>
#include <set>
using namespace std;
 
int main()
{
    int n = 0, m = 0;
    cin >> n >> m;
    set<int> s;
    int tmp = 0;
    while(n--)
    {
        cin >> tmp;
        s.insert(tmp);
    }
    while(m--)
    {
        cin >> tmp;
        s.insert(tmp);
    }
    auto it = s.begin();
    while(it != s.end())
    {
        cout << *it << " ";
        ++it;
    }
    return 0;
}